import React from 'react';
import axios from 'axios';
import { useState, useEffect } from 'react'
// import { useHistory } from 'react-router-dom';
type Props = {}
type listItemType = {
    id: number
    list_pic_url: string,
}
export default function Home({ }: Props) {
    const [list, setList] = useState<Array<listItemType>>([])
    useEffect(() => {
        axios.get('http://kumanxuan1.f3322.net:8001/index/index').then(res => {
            console.log('res', res);
            setList(res.data.data.newGoodsList)
        })
    }, [])
    // const his = useHistory()
    return (
        <div>
            <ul>
                {
                    list.map(item => <li key={item.id} onClick={() => {
                        //  his.push('/detail?id=' + item.id)
                        // his.push('/detail/' + item.id)
                    }}>
                        <img src={item.list_pic_url} />
                    </li>)
                }
            </ul>
        </div>
    )
}